package com.hmall.api.feign.fallback;

import java.util.Collection;
import java.util.List;

import com.hmall.api.dto.ItemDTO;
import com.hmall.api.feign.SearchRemote;
import com.hmall.common.utils.CollUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @Author: suren@517na.com
 * @CreateTime: 2025-04-07
 * @Description:
 */
@Slf4j
public class SearchRemoteFallback implements FallbackFactory<SearchRemote> {

    @Override
    public SearchRemote create(Throwable cause) {
        return new SearchRemote() {
            @Override
            public List<ItemDTO> queryItemByIds(Collection<Long> ids) {
                log.error("远程调用SearchRemote#queryItemByIds方法出现异常，参数：{}", ids, cause);
                // 查询购物车允许失败，查询失败，返回空集合
                return CollUtils.emptyList();
            }
        };
    }
}
